package com.huatai.bimonitor.mapper;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.huatai.bimonitor.entity.MqMqttClientEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author songxiude
 * @description 针对表【mq_mqtt_client(mqtt链接信息表)】的数据库操作Mapper
 * @createDate 2024-07-15 14:36:47
 * @Entity com.huatai.bi.MqMqttClient
 */
public interface MqMqttClientMapper extends BaseMapper<MqMqttClientEntity> {

	@Select("<script>" +
		"SELECT COUNT(*) as ct,ip_port FROM `mq_mqtt_client` WHERE " +
		"ip_port IN" +
		"<foreach item='item' index='index' collection='ips' open='(' separator=',' close=')'>" +
		"#{item}" +
		"</foreach>" +
		"GROUP BY ip_port ORDER BY ct limit 1" +
		"</script>")
	JSONObject getMinClient(@Param("ips") List<String> ips);
}




